package com.aaa.service.imp;

import com.aaa.mapper.StudentMapper;
import com.aaa.pojo.Student;
import com.aaa.service.IStudentService;
import com.aaa.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements IStudentService {

    @Autowired
    private StudentMapper studentMapper;
    @Override
    public Result findAll() {
        List<Student> studentList = studentMapper.findAll();
        return new Result(200,"查询学生信息成功",studentList);
    }

    @Override
    public Result findById(Integer sid) {
        Student student = studentMapper.findById(sid);
        return new Result(200,"查询信息成功",student);
    }

    @Override
    public Result insert(Student student) {
        Integer insert = studentMapper.insert(student);
        return new Result(200,"添加成功",insert);
    }

    @Override
    public Result delete(Integer sid) {
        Integer delete = studentMapper.delete(sid);
        return new Result(200,"删除成功",delete);
    }

    @Override
    public Result update(Student student) {
        Integer update = studentMapper.update(student);
        return new Result(200,"修改成功",update);
    }
}
